<!-- index.html (ch08www project) -->
{% extends "django08/base.html" %}
{% block title %}我有话要说{% endblock %}
{% block content %}
<div class='container'>
{% if message %}
    <div class='alert alert-warning'>{{ message }}</div>
{% endif %}
<form name='my form' action="{% url 'django08:django08_home' %}" method='GET'>
    现在的心情：<br/>
    {% for m in moods %}
    <input type='radio' name='mood' value='{{ m.status }}'>{{ m.status }}
    {% endfor %}
    <br/>
    心情留言板：<br/>
    <textarea name='user_post' rows=3 cols=70></textarea><br/>
    <label for='user_id'>你的昵称：</label>
    <input id='user_id' type='text' name='user_id'>
    <label for='user_pass'>张贴/删除密码：</label>
    <input id='user_pass' type='password' name='user_pass'><br/>
    <input type='submit' value='张贴'>
    <input type='reset' value='清除重填'>
</form>
<div class='row'>
    <div class='col-md-12'>
        <div class='panel panel-default'>
            <div class='panel-heading' align=center>
            <h3>~~宝宝心里苦，宝宝只在这里说~~</h3>
    </div>
</div>

<script>
function go_delete(id){
    var user_pass = document.getElementById('user_pass').value;
    if (user_pass != "") {
        var usr = '/django08/' + id + '/' + user_pass;
        window.location = usr;
    }
}
</script>

{% for foo in test %}
        {% cycle "<div class='row'> <div class='col-md-4'>" "<div class='col-md-4'>" "<div class='col-md-4'>" %}
        <div class='panel panel-primary'>

            <div class='panel-body'>{{ foo | linebreaks }}</div>

        </div>
        {% cycle "" "" "</div>"%}
        </div>
{% endfor %}
       </div>
<p>------------------</p>

{% for p in posts %}
    {% cycle "<div class='row'> <div class='col-md-4'>" "<div class='col-md-4'>" "<div class='col-md-4'>" %}
        <div class='panel panel-primary'>
            <div class='panel-heading'>【{{ p.nickname }}】觉得{{ p.mood }}</div>
            <div class='panel-body'>{{ p.message | linebreaks }}</div>
            <div class='panel-footer' align='right'>
                <i><small>{{ p.pub_time }}</small></i>
                <span class="glyphicon glyphicon-trash" onclick='go_delete({{p.id}})'></span>
            </div>
        </div>
    </div>
    {% cycle "" "" "</div>"%}
{% endfor %}
</div>
{% endblock %}